package com.dytj.dao;

import java.sql.Connection;
import java.sql.DriverManager;

public class DBUtil {
	private static Connection conn;
	public static Connection getConn(){
		try{
			String url="jdbc:mysql://localhost:3306/dytj";
			String username="root";
			String password="123456";
			Class.forName("com.mysql.jdbc.Driver");
			conn=DriverManager.getConnection(url,username,password);
			if(conn!=null){
				System.out.println("数据库连接成功。");
			}else{
				System.out.println("数据库连接失败。");
			}
		}catch(Exception e){
			e.printStackTrace();
		}
		return conn;
	}
}
